//更具目录views/modules/文件夹下的所有vue模板生成指定的路由匹配规则
//const files = require.context('@/views/modules',true,/\.vue$/) //使用webpack的API require.context
const files = import.meta.glob('../views/modules/*.vue')

let generator = []
//../views/modules/SMART.vue
Object.keys(files).forEach(key=>{
    const compath = key.replace(/(\..\/|\.vue)/g, '')
    generator.push({
        path: `/${compath.substring(compath.lastIndexOf('/') +1)}`,
        name: compath.substring(compath.lastIndexOf('/') +1),
        component:files[key]
      })
    
})


const routes = [{
    ...generator
}]

export default routes